import React from "react";
import ReactDOM from "react-dom";
import { ApolloClient, InMemoryCache, HttpLink, from } from "apollo-boost";
import { ApolloProvider } from "@apollo/react-hooks";
import { onError } from "apollo-link-error";

import "./index.css";
import App from "./App";
import * as serviceWorker from "./serviceWorker";

const errorLink = onError(({ response, graphQLErrors, networkError }) => {});

const httpLink = new HttpLink({
  uri: "http://localhost:4000/graphql",
  credentials: "include"
});

const client = new ApolloClient({
  link: from([errorLink, httpLink]),
  cache: new InMemoryCache(),
  defaultOptions: {}
});

ReactDOM.render(
  <ApolloProvider client={client}>
    <App />
  </ApolloProvider>,
  document.getElementById("root")
);

serviceWorker.unregister();
